package com.example.boot6rabbitmqalipay.controller;

import com.example.boot6rabbitmqalipay.service.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class OrderController {

    @Autowired
    OrderService orderService;

    @RequestMapping("/transfer")
    public @ResponseBody String transferAmount(String userId,int messageId,int amount) {
        try {
            orderService.updateAmount(amount, userId, messageId);
        }catch (Exception e) {
            return "fail";
        }
        return "OK";
    }

    @RequestMapping("/callback")
    public String callback(String param) {
        try {
            orderService.updateMessage(param);
        }catch (Exception e) {
            return "fail";
        }
        return "Ok";
    }
}
